<template>
  <view class="goods-desc">
    <Form title="商品描述">
      <!-- <FormItem label="商品描述"></FormItem> -->
      <FormItem :show-label="false">
        <textarea v-model="formData.desc" :maxlength="70" placeholder="请输入商品详细描述(选填)"></textarea>
      </FormItem>
    </Form>
  </view>
</template>

<script>
import Form from "../../../components/public/Form/index.vue";
import FormItem from "../../../components/public/FormItem/index.vue";
import { mapState, mapMutations } from "vuex";
export default {
  components: { Form, FormItem },
  props: {
    mode: {
      type: String,
      default: () => "add" // add modify
    }
  },
  data() {
    return {
      formData: {
        desc: ""
      }
    };
  },
  computed: {
    ...mapState({
      goodsInfo: state => state.goods.goodsInfo
    })
  },
  watch: {
    ["formData.desc"]() {
      this.SET_GOODS_INFO(this.formData);
    }
  },
  created() {
    if (this.goodsInfo.id && this.mode == "modify") this.init();
  },
  methods: {
    ...mapMutations({
      SET_GOODS_INFO: "SET_GOODS_INFO"
    }),
    init() {
      for (const key in this.formData) {
        this.formData[key] = this.goodsInfo[key];
      }
    },
    getData() {
      return this.formData;
    }
  }
};
</script>

<style scoped lang="scss">
.goods-desc {
}
</style>
